import { Component } from "cc";
import { AutoOff, EventManager } from "./EventManager";
import { EventType } from "./EventType";

export class MyComponent extends Component {
    onLoad() {
        // 使用装饰器绑定自动移除
        this.registerEvents();
    }

    @AutoOff(EventManager.getInstance())
    registerEvents() {
        EventManager.getInstance().on(EventType.PLAYER_LEVEL_UP, this.onLevelUp, this);
    }

    onLevelUp() {
        // ...
    }
}
